#include <bits/stdc++.h>
using namespace std;
// #define int long long
bool areSame(vector<string> vs, vector<int> currStrings)
{
int is = vs[currStrings[0]].size();
for (int i = 0; i < is; i++)
{
bool samei = true;
samei &= vs[currStrings[1]][i] == vs[currStrings[0]][i];
samei &= vs[currStrings[2]][i] == vs[currStrings[0]][i];
if (samei)
return true;
}
return false;
}
bool areDifferent(vector<string> vs, vector<int> currStrings)
{
int is = vs[currStrings[0]].size();
bool diffrent = true;
for (int i = 0; i < is; i++)
{
bool localDifferent = true;
localDifferent &= vs[currStrings[1]][i] != vs[currStrings[0]][i];
localDifferent &= vs[currStrings[2]][i] != vs[currStrings[0]][i];
diffrent &= localDifferent;
}
return diffrent;
}
int arr[1501][1501];
/*
Max Freq of feature in card number.
n=8
k=3
134 224 521
SET SET SET
5cards with 1st card == S forms group in bw
5cards with 3 cards whose 1st != S form groups with d
NS-1 N-1 N-1
- - -
*/
bool check(vector<int> &arr, int prevPos, int prevEle)
{
int currEle = prevEle + 1;
int n = arr.size();
if (currEle > n)
return true;
int currPos = find(arr.begin(), arr.end(), currEle) - arr.begin();
if (currPos > prevPos)
{
if (currPos == prevPos + 1)
return check(arr, currPos, currEle);
else
return false;
}
bool wrong = true;
for (int i = currPos + 1; i < prevPos; i++)
{
if (arr[i] != currEle + 1)
{
wrong = false;
break;
}
currEle++;
}
return wrong && check(arr, currPos, currEle);
}
void solve()
{
int n;
cin >> n;
vector<int> arr(n);
map<int, int> item2pos;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
item2pos[arr[i]] = i;
}
int curr = 1;
int end = n;
while (curr <= n)
{
int pos = item2pos[curr];
bool ans = true;
for (int i = pos + 1; i < end; i++)
{
ans &= arr[i] == curr + 1;
curr++;
}
if (!ans)
{
cout << "No";
return;
}
end = pos;
curr++;
}
cout << "Yes";
}
signed main()
{
int t = 1;
cin >> t;
while (t--)
{
solve();
cout << endl;
}
}
8A - Train and Peter | 591A - Wizards' Duel |
1703G - Good Key Bad Key | 1705A - Mark the Photographer |
1707A - Doremy's IQ | 1706B - Making Towers |
1325B - CopyCopyCopyCopyCopy | 1649C - Weird Sum |
1324B - Yet Another Palindrome Problem | 525A - Vitaliy and Pie |
879A - Borya's Diagnosis | 1672B - I love AAAB |
1673A - Subtle Substring Subtraction | 1345A - Puzzle Pieces |
711A - Bus to Udayland | 779B - Weird Rounding |
1703D - Double Strings | 1704C - Virus |
63A - Sinking Ship | 1704B - Luke is a Foodie |
298B - Sail | 239A - Two Bags of Potatoes |
1704E - Count Seconds | 682A - Alyona and Numbers |
44A - Indian Summer | 1133C - Balanced Team |
1704A - Two 0-1 Sequences | 1467A - Wizard of Orz |
1714E - Add Modulo 10 | 1714A - Everyone Loves to Sleep |